package com.ns;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class Adapter extends RecyclerView.Adapter<Adapter.ItemViewHolder> {

        private Context context;
        private List<Item> mItems;

        public Adapter(Context context, List<Item> items) {
                this.context = context;
                this.mItems = items;
        }

        @NonNull
        @Override
        public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                View view = LayoutInflater.from(context).inflate(R.layout.item,  null, false);
                return new ItemViewHolder(view);
        }

        @Override
        public void onBindViewHolder(@NonNull ItemViewHolder holder, int position) {
                Log.d("TAG", mItems.get(position).getContent());
                holder.mViewContent.setText(mItems.get(position).getContent());
        }

        @Override
        public int getItemCount() {
                Log.d("TAG", "mItems: " + mItems.size());
                return mItems.size();
        }

        public class ItemViewHolder extends  RecyclerView.ViewHolder {

                TextView mViewContent;

                public ItemViewHolder(@NonNull View itemView) {
                        super(itemView);
                        mViewContent = itemView.findViewById(R.id.content);
                }
        }
}
